package com.atguigu.gmall.item.controller;

import com.atguigu.gmall.common.result.Result;
import com.atguigu.gmall.item.service.ItemService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 *
 * 商品详情页完整数据对外接口
 * @author zjiajia
 * @date 2021/1/30 17:17
 */

@RestController
@RequestMapping("api/item")
public class ItemController {
    /**
     * 商品详情管理service组件
     */
    @Autowired
    private ItemService itemService;

    /**
     * 通过skuId 获取到商品详情页数据
     * @param skuId skuId
     * @return      商品详情数据
     */
    @RequestMapping("{skuId}")
    public Result getItem(@PathVariable Long skuId){
        Map<String, Object> result = itemService.getBySkuId(skuId);
        return Result.ok(result);
    }
}
